function addToBasket(id, quantity)
			{
				if(quantity < 1 || id < 1)
					return;
				
				var newBook = new Object();
				newBook.id = id;
				newBook.quantity = quantity;
				
				var currentBasketJSON = $.cookie('basket');
				
				var nextBasket = null;
				if(currentBasketJSON == null)
				{
					nextBasket = new Array();
					nextBasket.push(newBook);
				}
				else
				{
					nextBasket  = $.evalJSON(currentBasketJSON);
					var found = false;
					
					for(var i = 0; i < nextBasket.length; i++)
					{
						if(nextBasket[i].id == id)
						{
							nextBasket[i].quantity = nextBasket[i].quantity + quantity;
							found = true;
							break;
						}
					}
					
					if(found == false)
					{
						nextBasket.push(newBook);	
					}
				}

				var nextBasketJSON = $.toJSON(nextBasket);
				$.cookie('basket', nextBasketJSON);
			}

function removeFromBasket(id, quantity)
{
	if(quantity < 1 || id < 1)
		return;
	
	var currentBasketJSON = $.cookie('basket');
	
	var nextBasket = null;
	if(currentBasketJSON == null)
	{
		return ;
	}
	else
	{
		nextBasket  = $.evalJSON(currentBasketJSON);
		
		var improvedBasket = new Array();
		
		for(var i = 0; i < nextBasket.length; i++)
		{
			if(nextBasket[i].id == id)
			{
				nextBasket[i].quantity = nextBasket[i].quantity - quantity;
			}
			if(nextBasket[i].quantity > 0)
				improvedBasket.push(nextBasket[i]);
		}
		
		nextBasket = improvedBasket;
	}

	var nextBasketJSON = $.toJSON(nextBasket);
	$.cookie('basket', nextBasketJSON);
}

function reloadAuthors(selectField)
{
	var selectInput = $(selectField);
	
	selectInput.empty();

	$.getJSON("services/authors/get", function(data) {
		$.each(data, function(i, item) {
			selectInput.append(new Option(item.name, item.id, true, true));
		});
	});
}
